import Vue from "vue";
import VueRouter from "vue-router";
import Login from '../components/Login.vue';
import Home from '../components/Home.vue';
import Show from '../components/Registration/Show.vue'
import Storagedan from '../components/Storage/Storagedan.vue'
import Charge from '../components/Registration/Charge.vue'
import Hospitalized from '../components/Hospital/Hospitalized.vue'
import Bunk from '../components/Hospital/Bunk.vue'
Vue.use(VueRouter);

const router = new VueRouter({
    routes: [

        { path: '/', redirect: '/login' },
        { path: '/login', component: Login },
        {
            path: '/home',
            component: Home,
            children: [
                { path: '/show', component: Show },
                { path: '/storagedan', component: Storagedan },
                { path: '/charge', component: Charge },
                { path: '/hospital', component: Hospitalized },
                { path: '/bunk', component: Bunk },
            ]
        },
    ]
});

// // 挂载路由导航守卫
// router.beforeEach((to,from,next) =>{
//     if(to.path === '/login') return next()
//     // 获取token
//     const tokenStr = window.sessionStorage.getItem('token')
//     // 判断是否携带token 否则返回到login
//     if(!tokenStr) return next('login')
//     next()
// })

export default router;
